I was trying to debug `test-pull-c`, and typing `Ctrl-C` in gdb
ended up sending `SIGINT` to trivial-httpd as well, killing it.
Daemonize a bit more properly to avoid this. I also followed the standard
`/dev/null` guidelines.
Closes: #643
Approved by: jlebon
#include "otutil.h"
#include <locale.h>
+#include <err.h>
#include <sys/socket.h>
#include <sys/prctl.h>
#include <signal.h>
goto out;
}
/* Child, continue */
+ if (setsid () < 0)
+ err (1, "setsid");
/* Daemonising: close stdout/stderr so $() et al work on us */
- fclose (stdout);
- fclose (stdin);
+ freopen("/dev/null", "r", stdin);
+ freopen("/dev/null", "w", stdout);
+ freopen("/dev/null", "w", stderr);
}
else
{